package main

import (
	"fmt"
	"github.com/astaxie/beego/logs"
)

func main() {
	fileName := "./logagent/conf.log"
	err := loadConf("ini", fileName)
	if err != nil {
		fmt.Print(err)
	}

	err = initLogger()
	if err != nil {
		fmt.Print(err)
		panic(err)
	}

	logs.Debug("日志初始化成功")

	err = initTailf(appConf.collectconf)
	if err != nil {
		logs.Error("init tailf faild", err)
		return
	}
	err = serverRun()
	if err != nil {
		logs.Error("init tailf faild", err)
		return
	}
	logs.Info("exit")
}

func serverRun() (err error) {
	for {
		msg := GetMsg()
		err = sendToKafka(msg)
		if err != nil {
			logs.Error("send to kafka err", err)
			continue
		}
	}
	return
}
